package com.microservice.microservicemovie;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

/**
 * @EnableHystrix 打开断路器
 * @EnableHystrixDashboard 开打断路器监控
 */
@EnableEurekaClient
@SpringBootApplication
@EnableHystrix
public class MicroserviceMovieHystrixApplication {

	/**
	 *  实现 Ribbon 自动化配置，作为负载平衡器客户端
	 * @return
	 */
	@Bean
	@LoadBalanced
	public RestTemplate restTemplate(){
		return new RestTemplate();
	}

	public static void main(String[] args) {
		SpringApplication.run(MicroserviceMovieHystrixApplication.class, args);
	}
}
